/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sistemas.sisgear.entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Jean
 */
@Entity
@Table(name = "template")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Template.findAll", query = "SELECT t FROM Template t"),
    @NamedQuery(name = "Template.findByIdTemplate", query = "SELECT t FROM Template t WHERE t.idTemplate = :idTemplate"),
    @NamedQuery(name = "Template.findByNombre", query = "SELECT t FROM Template t WHERE t.nombre = :nombre"),
    @NamedQuery(name = "Template.findByAutor", query = "SELECT t FROM Template t WHERE t.autor = :autor"),
    @NamedQuery(name = "Template.findByFecha", query = "SELECT t FROM Template t WHERE t.fecha = :fecha"),
    @NamedQuery(name = "Template.findByConsulta", query = "SELECT t FROM Template t WHERE t.consulta = :consulta")})
public class Template implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "idTemplate")
    private String idTemplate;
    @Size(max = 45)
    @Column(name = "Nombre")
    private String nombre;
    @Size(max = 20)
    @Column(name = "Autor")
    private String autor;
    @Column(name = "Fecha")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    @Size(max = 1000)
    @Column(name = "Consulta")
    private String consulta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idTemplate")
    private List<Seccion> seccionList;

    public Template() {
    }

    public Template(String idTemplate) {
        this.idTemplate = idTemplate;
    }

    public String getIdTemplate() {
        return idTemplate;
    }

    public void setIdTemplate(String idTemplate) {
        this.idTemplate = idTemplate;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getAutor() {
        return autor;
    }

    public void setAutor(String autor) {
        this.autor = autor;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public String getConsulta() {
        return consulta;
    }

    public void setConsulta(String consulta) {
        this.consulta = consulta;
    }

    @XmlTransient
    public List<Seccion> getSeccionList() {
        return seccionList;
    }

    public void setSeccionList(List<Seccion> seccionList) {
        this.seccionList = seccionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTemplate != null ? idTemplate.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Template)) {
            return false;
        }
        Template other = (Template) object;
        if ((this.idTemplate == null && other.idTemplate != null) || (this.idTemplate != null && !this.idTemplate.equals(other.idTemplate))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.sistemas.sisgear.entidades.Template[ idTemplate=" + idTemplate + " ]";
    }
    
}
